﻿<%@ Page Title="Manage ServiceEndpoints" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ManageServiceEnpoints.aspx.cs" Inherits="NIntegrate.Configuration.UI.ManageServiceEnpoints" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2>Manage ServiceEndpoints</h2>
    <div class="bottomhyperlink"><img alt="Add new service endpoint" src="Images/plus.gif" /><asp:LinkButton 
            ID="btnShowAddNewPanel" runat="server" Text="Add new service endpoint" 
            onclick="btnShowAddNewPanel_Click"></asp:LinkButton></div>
    <br />
    <asp:GridView CssClass="gridview"
        ID="gvServiceEndpoints" runat="server" 
        DataSourceID="dsServiceEndpoints"
        DataKeyNames="Service_id, Endpoint_id, Farm_id"
        AllowSorting="true"
        AutoGenerateDeleteButton="true"
        AutoGenerateColumns="false"
        AutoGenerateEditButton="true" onrowcommand="gvServiceEndpoints_RowCommand">
        <Columns>
            <asp:TemplateField HeaderText="Service" SortExpression="Service_id">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlServices" runat="server" SelectedValue='<%# Bind("Service_id") %>' DataSourceID="dsServices" DataTextField="ServiceName" DataValueField="Service_id" Enabled="false"></asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlServices" runat="server" SelectedValue='<%# Bind("Service_id") %>' DataSourceID="dsServices" DataTextField="ServiceName" DataValueField="Service_id"></asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>     
            <asp:TemplateField HeaderText="Endpoint" SortExpression="Endpoint_id">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlEndpoints" runat="server" SelectedValue='<%# Bind("Endpoint_id") %>' DataSourceID="dsEndpoints" DataTextField="EndpointName" DataValueField="Endpoint_id" Enabled="false"></asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlEndpoints" runat="server" SelectedValue='<%# Bind("Endpoint_id") %>' DataSourceID="dsEndpoints" DataTextField="EndpointName" DataValueField="Endpoint_id"></asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>            
            <asp:TemplateField HeaderText="Farm" SortExpression="Farm_id">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlFarms" runat="server" SelectedValue='<%# Bind("Farm_id") %>' DataSourceID="dsFarms" DataTextField="FarmName" DataValueField="Farm_id" Enabled="false"></asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlFarms" runat="server" SelectedValue='<%# Bind("Farm_id") %>' DataSourceID="dsFarms" DataTextField="FarmName" DataValueField="Farm_id"></asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField HeaderText="Active" DataField="Active" SortExpression="Active" />
        </Columns>
        <SelectedRowStyle BackColor="LightYellow" />
    </asp:GridView>
    <asp:Panel ID="panelBottom" runat="server" CssClass="panelBottom">
        <asp:DetailsView ID="dvAddServiceEndpoint" runat="server" Visible="false"
            DataSourceID="dsServiceEndpoints" DefaultMode="Insert"
            AutoGenerateRows="false"
            AutoGenerateInsertButton="true"
            CssClass="detailstable" onitemcommand="dvAddServiceEndpoint_ItemCommand" 
            oniteminserted="dvAddServiceEndpoint_ItemInserted">
            <Fields>
                <asp:TemplateField HeaderText="Service">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlServices" runat="server" SelectedValue='<%# Bind("Service_id") %>' DataSourceID="dsServices" DataTextField="ServiceName" DataValueField="Service_id"></asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>     
                <asp:TemplateField HeaderText="Endpoint">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlEndpoints" runat="server" SelectedValue='<%# Bind("Endpoint_id") %>' DataSourceID="dsEndpoints" DataTextField="EndpointName" DataValueField="Endpoint_id"></asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>            
                <asp:TemplateField HeaderText="Farm">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlFarms" runat="server" SelectedValue='<%# Bind("Farm_id") %>' DataSourceID="dsFarms" DataTextField="FarmName" DataValueField="Farm_id"></asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:CheckBoxField HeaderText="Active" DataField="Active" />
            </Fields>
        </asp:DetailsView>
    </asp:Panel>
    <ni:QueryDataSource ID="dsServiceEndpoints" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
    <ni:QueryDataSource ID="dsServices" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
    <ni:QueryDataSource ID="dsEndpoints" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
    <ni:QueryDataSource ID="dsFarms" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
</asp:Content>
